package it.javaweb.dao.jdbc;

import java.util.List;

import javax.sql.DataSource;

import it.javaweb.beans.Materia;
import it.javaweb.dao.MateriaDAO;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;

/**
 * Classe che implementa MateriaDAO
 * */
public class MateriaDAOImpl implements MateriaDAO{

	private SimpleJdbcTemplate simpleJdbcTemplate;
	
	@Autowired
	public void init(DataSource dataSource) {
		this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
	}
	
	@Override
	public Materia get4Descrizione(String descrizione) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Materia get4ID(int ID) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Materia> getAll() {
		List<Materia> materie = this.simpleJdbcTemplate.query(
				"SELECT * FROM materia",
				new MateriaRowMapper());
		return materie;
	}

}
